package com.inno.auth.infra.basic.service.impl;

import com.inno.auth.infra.basic.entity.PlannerFeedbackInfo;
import com.inno.auth.infra.basic.mapper.PlannerFeedbackInfoDao;
import com.inno.auth.infra.basic.service.PlannerFeedbackInfoService;
import jakarta.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;



/**
 * 意见反馈表(PlannerFeedbackInfo)表服务实现类
 *
 * @author makejava
 * @since 2025-01-03 21:32:44
 */
@Service("plannerFeedbackInfoService")
public class PlannerFeedbackInfoServiceImpl implements PlannerFeedbackInfoService {
    @Resource
    private PlannerFeedbackInfoDao plannerFeedbackInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PlannerFeedbackInfo queryById(Long id) {
        return this.plannerFeedbackInfoDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param plannerFeedbackInfo 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<PlannerFeedbackInfo> queryByPage(PlannerFeedbackInfo plannerFeedbackInfo, PageRequest pageRequest) {
        long total = this.plannerFeedbackInfoDao.count(plannerFeedbackInfo);
        return new PageImpl<>(this.plannerFeedbackInfoDao.queryAllByLimit(plannerFeedbackInfo, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param plannerFeedbackInfo 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerFeedbackInfo insert(PlannerFeedbackInfo plannerFeedbackInfo) {
        this.plannerFeedbackInfoDao.insert(plannerFeedbackInfo);
        return plannerFeedbackInfo;
    }

    /**
     * 修改数据
     *
     * @param plannerFeedbackInfo 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerFeedbackInfo update(PlannerFeedbackInfo plannerFeedbackInfo) {
        this.plannerFeedbackInfoDao.update(plannerFeedbackInfo);
        return this.queryById(plannerFeedbackInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.plannerFeedbackInfoDao.deleteById(id) > 0;
    }

    @Override
    public com.github.pagehelper.Page<PlannerFeedbackInfo> queryPage(PlannerFeedbackInfo plannerFeedbackInfo) {
        return this.plannerFeedbackInfoDao.queryPage(plannerFeedbackInfo);
    }
}
